const Mock = require('mockjs')

const data = Mock.mock({
  'roledata|20': [{
    roleId: '@id',
    roleCode: '@id',
    roleName: '@cname',
    roleType: '@cname',
    followAppName: '@cname',
    isSelected: '@Boolean(true,false)'
  }]
})
module.exports = [// 查询列表
  {
    url: '/businessUser/userRoleList',
    type: 'get',
    response: (config) => {
      const items = data.roledata
      // config是传进来的参数对象
      const {
        pageNo = 1, pageSize = 10, roleName
      } = config.query
      const searchList = items.filter((item) => item.roleName.indexOf(roleName) !== -1)
      const pageList = searchList.filter((item, index) => index < pageSize * pageNo && index >= pageSize * (pageNo - 1))
      return {
        code: '00000',
        data: {
          totalRows: items.length,
          rows: pageList
        }
      }
    }
  }
]
